﻿@{
    Layout = "~/Views/Shared/_LayoutMain.cshtml";
}
@{
    //消费类型
    List<ConsumeSys.Model.ConsumeType> typeList = (List<ConsumeSys.Model.ConsumeType>)ViewData["typeList"];
    //用户集合
    List<ConsumeSys.Model.User> userList = (List<ConsumeSys.Model.User>)ViewData["userList"];
}
<div>
    <table>
        <tr>
            <td>消费名称：</td>
            <td>
                <input type="text" name="c_Name" value="" />
            </td>
        </tr>
        <tr>
            <td>消费类型：</td>
            <td>
                <select name="c_CTypeId">
                    <option value="0">--请选择--</option>
                    @{
                        if (typeList != null && typeList.Count > 0)
                        {
                            foreach (ConsumeSys.Model.ConsumeType item in typeList)
                            {
                                <option value="@item.id">@item.ct_TypeName</option>
                            }
                        }
                    }
                </select>
            </td>
        </tr>
        <tr>
            <td>消费人（付钱人）：</td>
            <td>
                <select name="c_UserId">
                    <option value="0">--请选择--</option>
                    @{
                        if (userList != null && userList.Count > 0)
                        {
                            foreach (ConsumeSys.Model.User item in userList)
                            {
                                <option value="@item.id">@item.u_RealName</option>
                            }
                        }
                    }
                </select>
            </td>
        </tr>
        @*<tr>
            <td>消费总金额：</td>
            <td>
                <input type="text" name="c_TotalPrice" value="" />
            </td>
        </tr>*@
        <tr>
            <td>实际付款金额：</td>
            <td>
                <input type="text" name="c_ActualPayment" value="" />
            </td>
        </tr>
        <tr>
            <td>参与总人数：</td>
            <td>
                <input type="text" name="c_PersonTotalCount" value="" />
            </td>
        </tr>
        <tr>
            <td>消费时间：</td>
            <td>
                <input type="text" name="c_CTime" readonly="readonly" onclick="WdatePicker()" value="@DateTime.Now.ToString("yyyy-MM-dd")" />
            </td>
        </tr>
        <tr>
            <td>备注：</td>
            <td>
                <textarea rows="10" cols="50" name="c_Remark"></textarea>
            </td>
        </tr>
        <tr>
            <td></td>
            <td>
                <input type="button" value="提交" onclick="Add()" />
            </td>
        </tr>
    </table>
    <script type="text/javascript">
        function Add() {
            $.ajax({
                type: "POST",
                url: "/Consume/AddConsume",
                data: {
                    c_Name: $("[name=c_Name]").val(),
                    c_CTypeId: $("[name=c_CTypeId] option:selected").val(),
                    c_UserId: $("[name=c_UserId] option:selected").val(),
                    //c_TotalPrice: $("[name=c_TotalPrice]").val(),
                    c_ActualPayment: $("[name=c_ActualPayment]").val(),
                    c_PersonTotalCount: $("[name=c_PersonTotalCount]").val(),
                    c_Remark: $("[name=c_Remark]").val(),
                    c_CTime: $("[name=c_CTime]").val()
                },
                success: function (d) {
                    if (d.Code == 200) {
                        $.messager.show({
                            title: '提示',
                            msg: '添加成功',
                            timeout: 2000,
                            showType: 'slide',
                            style: {
                                right: '',
                                top: 100,
                                bottom: ''
                            }
                        });
                    } else {
                        $.messager.alert('Warning',d.Msg);
                    }             
                }
            });
        }
    </script>
</div>
